<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Unicorn Admin</title>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/dist/css/bootstrap-min.css" />
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/dist/css/bootstrap-responsive.min.css" />
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/dist/css/uniform.css" />
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/dist/css/select2.css" />
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/dist/css/unicorn.main.css" />
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/dist/css/unicorn.grey.css"
	class="skin-color" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
	

	<div id="header">
		<h1>
			<a href="./dashboard.html">独角兽管理员</a>
		</h1>
	</div>

	<!-- <div id="search">
			<input type="text" placeholder="Search here..." /><button type="submit" class="tip-right" title="Search"><i class="icon-search icon-white"></i></button>
		</div> -->
	<div id="user-nav" class="navbar navbar-inverse">
		<ul class="nav btn-group">
			  <!-- 默认头像 -->
				<li><img
					src="${pageContext.request.contextPath}/dist/img/0.jpg"
					style="border-radius: 50%; width: 30px; height: 30px; margin-top: 0px;" /></li>
			<%-- </c:if>
			<!-- 自定义头像 -->
			<c:if test="${sessionScope.users.adminImg != null} }">
				<li><img
					src="${pageContext.request.contextPath}/DownloadFileServlet?fileName=${sessionScope.users.adminImg}"
					style="border-radius: 50%; width: 30px; height: 30px; margin-top: 0px;" /></li>
			</c:if> --%>
			<li id="account"><a href="#">${sessionScope.users.adminAccount }</a></li>
			<li class="btn btn-inverse"><a title=""
				href="${pageContext.request.contextPath}/EduControllerByGyx?op=addminExit"><i
					class="icon icon-share-alt"></i> <span class="text">退出</span></a></li>
		</ul>
	</div>

	<div id="sidebar">
		<a href="#" class="visible-phone"><i class="icon icon-home"></i>
			首页</a>
		<ul>
			<li class="active"><a
				href="${pageContext.request.contextPath}/mvc/index.jsp"><i
					class="icon icon-home"></i> <span>首页</span></a></li>
			<li class="submenu"><a href="#"><i class="icon icon-th-list"></i>
					<span>管理员事项</span> <span class="label">2</span></a>
				<ul>
					<li><a
						href="${pageContext.request.contextPath}/mvc/form-validation.jsp">管理员列表</a></li>
					<li><a
						href="${pageContext.request.contextPath}/mvc/form-addadmin.jsp">添加管理员</a></li>
				</ul></li>
			<li class="submenu"><a href="#"><i class="icon icon-th-list"></i>
					<span>详细数据表</span> <span class="label">2</span></a>
				<ul>
					<li><a
						href="${pageContext.request.contextPath}/mvc/userstable.jsp">用户列表</a></li>
					<li><a
						href="${pageContext.request.contextPath}/mvc/articletable.jsp">文章列表</a></li>
				</ul></li>
			<li><a href="${pageContext.request.contextPath}/mvc/charts.jsp"><i
					class="icon icon-signal"></i> <span>数据信息统计</span></a></li>
		</ul>
	</div>

	<div id="style-switcher">
		<i class="icon-arrow-left icon-white"></i> <span>Style:</span> <a
			href="#grey"
			style="background-color: #555555; border-color: #aaaaaa;"></a> <a
			href="#blue" style="background-color: #2D2F57;"></a> <a href="#red"
			style="background-color: #673232;"></a>
	</div>

	<div id="content">
		<div id="content-header">
			<h1>管理员</h1>

		</div>
		<div id="breadcrumb">
			<a href="index.jsp" title="Go to Home" class="tip-bottom"><i
				class="icon-home"></i> 主页面</a> <a href="#" class="current">管理员列表</a>
		</div>
		<div class="container-fluid">
			<div class="row-fluid">
				<div class="span12">
					<div class="widget-box">
						<div class="widget-title">
							<span class="icon"> <i class="icon-align-justify"></i>
							</span>
							<h5>基本信息</h5>

						</div>
						<div class="widget-content nopadding">
							<table class="table table-bordered table-striped">
								<thead>
									<tr>
										<th>管理员编号</th>
										<th>管理员账号</th>
										<th>管理员密码</th>
										<th>管理员等级</th>
										<th>操作</th>
									</tr>
								</thead>
                                    
								<tbody id="allAdmins">
                                   
								</tbody>

							</table>
						</div>
					</div>
				</div>
			</div>
		</div>

	</div>


	<script src="${pageContext.request.contextPath}/dist/js/jquery.min.js"></script>
	<script
		src="${pageContext.request.contextPath}/dist/js/jquery.ui.custom.js"></script>
	<script
		src="${pageContext.request.contextPath}/dist/js/bootstrap-min.js"></script>
	<script
		src="${pageContext.request.contextPath}/dist/js/jquery.uniform.js"></script>
	<script src="${pageContext.request.contextPath}/dist/js/select2.min.js"></script>
	<script
		src="${pageContext.request.contextPath}/dist/js/jquery.validate.js"></script>
	<script src="${pageContext.request.contextPath}/dist/js/unicorn.js"></script>
	<script
		src="${pageContext.request.contextPath}/dist/js/unicorn.form_validation.js"></script>
</body>
<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
<script>
$(function(){
	//发送ajax请求用户列表
	$.get("${pageContext.request.contextPath}/EduControllerByGyx",{op:"adminsList"},function(data){
		showAdmins(data);		 
	},"json")
}) 
    //刷新显示管理员信息
	  function showAdmins(data){
	//每次遍历前清空数据
	 $("#allAdmins").empty();
     //遍历
     $.each(data,function(n,admins){
    	 var button='';
    	 var adminPwd ="";
    	 //判断登录进来的管理员等级 
    	   if(${sessionScope.users.adminLevel} == 2){  
		    adminPwd=admins.adminPwd;
			if(admins.adminLevel == 1){
				button='<a href=\"javascript:logoutAdmin('+admins.adminId+')\" ><button class=\"btn btn-danger btn-primary btn-xs\">注销</button></a>';
			}else if(admins.adminLevel == 0){
				button='<a href=\"javascript:startAdmin('+admins.adminId+')\" ><button class=\"btn btn-info btn-primary btn-xs\">启用</button></a>';
			}else{
			    button='';
			}
    	  }else{
    		  adminPwd="*******";   		  
    	  }  
    	 $("#allAdmins").append("<tr>\r\n" + 
					"									<td>"+admins.adminId+"</td>\r\n" + 
					"									<td>"+admins.adminAccount+"</td>\r\n" + 
					"									<td>"+adminPwd+"</td>\r\n" + 
					"									<td>"+admins.adminLevel+"</td>\r\n" + 
					"									<td>"+button+"</td>\r\n" +	
					"									</tr>");
    	 
     })
}
  
		      //修改管理员等级
			 //注销
			 function logoutAdmin(adminId){
				 $.get("${pageContext.request.contextPath}/EduControllerByGyx",{op:"logoutAdmin",adminId:adminId},function(data){
					 showAdmins(data);
				 },"json");
			 }
			 //启用
			 function startAdmin(adminId){
				 $.get("${pageContext.request.contextPath}/EduControllerByGyx",{op:"startAdmin",adminId:adminId},function(data){
					 showAdmins(data);
				 },"json");
			 }
			 
	 
	 
 </script>
 <style>
	 
	 #allAdmins td{	
	 text-align: center;	
	 }
	
	 </style>

</html>
